package com.secondhand.project.service.impl;

import cn.hutool.core.date.DateUtil;
import com.secondhand.common.utils.SecurityUtils;
import com.secondhand.project.domain.Help;
import com.secondhand.project.mapper.HelpMapper;
import com.secondhand.project.service.IHelpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HelpServiceImpl implements IHelpService {
    @Autowired
    private HelpMapper helpMapper;

    @Override
    public Help selectHelpById(Long id) {
        return helpMapper.selectHelpById(id);
    }

    @Override
    public List<Help> selectHelpList(Help help) {
        return helpMapper.selectHelpList(help);
    }

    @Override
    public int insertHelp(Help help) {
        help.setUserId(SecurityUtils.getUserId());
        help.setTime(DateUtil.now());
        return helpMapper.insertHelp(help);
    }

    @Override
    public int updateHelp(Help help) {
        return helpMapper.updateHelp(help);
    }

    @Override
    public int deleteHelpByIds(Long[] ids) {
        return helpMapper.deleteHelpByIds(ids);
    }

    @Override
    public int deleteHelpById(Long id) {
        return helpMapper.deleteHelpById(id);
    }
}
